import request from "@/utils/request"

/**
 * 获取组织结构数据
 * @returns {AxiosPromise}
 */
export const getDepartment = () => {
  return request({
    url: '/company/department',
    method: 'GET'
  })
}

/**
 * 获取部门负责人的数据
 * @returns {AxiosPromise}
 */
export const getManagerList = () => {
  return request({
    url: '/sys/user/simple',
    method: 'GET'
  })
}

/**
 * 新增组织
 * @param data
 * @returns {*}
 */
export const addDepartment = (data) => {
  return request({
    url: '/company/department',
    method: 'POST',
    data
  })
}

/**
 * 获取部门详情
 * @param id
 * @returns {AxiosPromise}
 */
export const getDepartmentDetail = (id) => {
  return request({
    url: `/company/department/${id}`,
    method: 'GET'
  })
}

/**
 * 更新部门
 * @param data
 * @returns {AxiosPromise}
 */
export const updateDepartment = (data) => {
  return request({
    url: `/company/department/${data.id}`,
    method: 'PUT',
    data
  })
}

/**
 * 删除部门
 * @param id
 * @returns {AxiosPromise}
 */
export const delDepartment = (id) => {
  return request({
    url: `/company/department/${id}`,
    method: 'DELETE'
  })
}
